public class Main {
    static class Solution {
        public int lengthOfLongestSubstring(String s) {
            int len = s.length();
            if(len == 0){
                return 0;
            }

            int[] count = new int[128];
            int l = 0, r = 0;
            int ans = 1;
            for(;r<len;r++){
                while(count[s.charAt(r)] != 0){
                    count[s.charAt(l++)]--;
                }
                count[s.charAt(r)]++;
                ans = Math.max(ans, r - l + 1);
                
            }
            return ans;
        }
    }
    public static void main(String[] args) {
        Solution solution = new Solution();
        System.out.println(solution.lengthOfLongestSubstring("pwwkew"));
    }
}
